home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / fileutil / eddy8h.zip / EDDYCOPY.BAT < prev    next >
DOS Batch File  |  1997-02-04  |  2KB  |  62 lines

  1.     @echo off
  2. : This batch file demonstrates how EDDY can be used to make a copy of a
  3. : file (with a new name, of course) in the current working directory.
  4. :
  5. : This is accomplished by putting an entry in EDDY.USE that names this
  6. : file (or one like it), and associates a filespec of "*.*" with it.
  7. :
  8. : The sample EDDY.USE that comes with the EDDY distribution package is
  9. : set up to demonstrate how this works (Example 13).
  10. :
  11. : Here's some batch code that will do the job...
  12. :
  13.     if &%1==& goto err
  14.     if &%2==& goto err
  15.     if not exist %2 goto doit
  16.     echo .
  17.     echo File "%2" already exists:
  18. :
  19. : The following lines, up to the "choice" command, are non-essential.
  20. : They are only used to ensure that the filename has a "." in it, so
  21. : that when it's used with the "dir" command, we don't list irrelevant
  22. : files.  The technique is from the July, 1992 issue of "PC Magazine",
  23. : which explains that a "/" as used in the "for" statement below peels
  24. : off the first byte of the argument string.
  25. :
  26.     set __xx=%2
  27.     :next
  28.     set __yy=%__xx%
  29.     for %%f in (/%__xx%) do set __xx=%%f
  30.     if .%__xx%==%__yy% goto dot
  31.     if %__xx%==. goto dot
  32.     if not &%__xx%==&%__yy% goto next
  33.     dir %2.
  34.     goto reset
  35.     :dot
  36.     dir %2
  37.     :reset
  38.     set __xx=
  39.     set __yy=
  40.     :
  41.     choice /c:yn "Overwrite "
  42.     if errorlevel 2 goto done
  43. :
  44. : If you are using a version of DOS that doesn't have the "choice" command,
  45. : you might replace the two lines above by something like this...
  46. :
  47. :   echo If you don't want to overwrite, press [^c]
  48. :   pause
  49. :
  50.     :doit
  51.     copy %1 %2
  52.     goto done
  53.     :err
  54.     echo Syntax:  EDDYCOPY  file-to-be-copied  filename-for-copied-file
  55.     :done
  56. :
  57. : NOTE -
  58. : This file illustrates one use of EDDY's PATCH command:  The last line below
  59. : has been truncated to get rid of the CR, LF, and ^z that would normally be
  60. : found at the end of a text file.  The result is that you don't get the
  61. : __extra__ DOS command line prompt when the batch file is run.  Of course,
  62. : if someone modifies this file, those 3 bytes will most likely reappear here.